/**
* @author:kellen
* @contact:xiekellen@hotmail.com
* @company:achivo-gz
* @created on:
* @modified on:
*/

package com.sasis.dao.ibatis;

import java.util.List;

import com.sasis.dao.ibatis.BaseDaoiBATIS;
import com.sasis.model.VipServiceReceivecar;
import com.sasis.dao.VipServiceReceivecarDao;

import org.springframework.orm.ObjectRetrievalFailureException;

public class VipServiceReceivecarDaoiBatis extends BaseDaoiBATIS implements VipServiceReceivecarDao {

    /**
     * @see com.sasis.dao.VipServiceReceivecarDao#getVipServiceReceivecars(com.sasis.model.VipServiceReceivecar)
     */
    public List getVipServiceReceivecars(final VipServiceReceivecar vipServiceReceivecar) {
          return getSqlMapClientTemplate().queryForList("getVipServiceReceivecars", vipServiceReceivecar);
    }

    /**
     * @see com.sasis.dao.VipServiceReceivecarDao#getVipServiceReceivecar(Integer id)
     */
    public VipServiceReceivecar getVipServiceReceivecar(Integer id) {
        VipServiceReceivecar vipServiceReceivecar = (VipServiceReceivecar) getSqlMapClientTemplate().queryForObject("getVipServiceReceivecar", id);

//        if (vipServiceReceivecar == null) {
//            throw new ObjectRetrievalFailureException(VipServiceReceivecar.class, id);
//        }

        return vipServiceReceivecar;
    }

    /**
     * @see com.sasis.dao.VipServiceReceivecarDao#saveVipServiceReceivecar(VipServiceReceivecar vipServiceReceivecar)
     */    
    public int saveVipServiceReceivecar(final VipServiceReceivecar vipServiceReceivecar) {
        Integer id = vipServiceReceivecar.getId();
        // check for new record
        if (id == null) {
            id = (Integer) getSqlMapClientTemplate().insert("addVipServiceReceivecar", vipServiceReceivecar);
        } else {
            getSqlMapClientTemplate().update("updateVipServiceReceivecar", vipServiceReceivecar);
        }
        if( id == null ) {
            throw new ObjectRetrievalFailureException(VipServiceReceivecar.class, id);
        }
        return id.intValue();
    }

    /**
     * @see com.sasis.dao.VipServiceReceivecarDao#removeVipServiceReceivecar(Integer id)
     */
    public void removeVipServiceReceivecar(VipServiceReceivecar vipServiceReceivecar) {
        getSqlMapClientTemplate().update("deleteVipServiceReceivecar",  vipServiceReceivecar);
    }
}
